package com.bw.controller;


import cn.hutool.core.lang.tree.Tree;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bw.conf.Result;
import com.bw.domain.SysUser;
import com.bw.feign.DeptFeignService;
import com.bw.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    SysUserService service;
    @Autowired
    DeptFeignService deptFeignService;

    @GetMapping("deptList")
    public Map<String, List<Tree<String>>> deptList(){
        List<Tree<String>> treeList = deptFeignService.list();
        Map<String,List<Tree<String>>> map=new HashMap<>();
        map.put("data",treeList);
        return map;
    }

    @RequestMapping("/list")
    public IPage<SysUser> list(Page page, @RequestBody SysUser sysUser){
        IPage<SysUser> pageList=service.pageList(page,sysUser);
        return pageList;
    }

    /**
     * 获取司机列表
     * @return
     */
    @GetMapping("/getDriverList")
    public Result<List<SysUser>> getDriverList(){
        List<SysUser> list=service.getDriverList();
        return Result.ok(list);
    }

}
